//
//  SampuxRegisterViewController.m
//  Sampux
//
//  Created by rzm on 16/7/4.
//  Copyright © 2016年 rzm. All rights reserved.
//

#import "SampuxRegisterViewController.h"
#import "SampuxRegisterView.h"
#import "SampuxLoginViewController.h"
#import "SampuxProtocolViewController.h"

@interface SampuxRegisterViewController ()
@property (nonatomic, strong) SampuxRegisterView *registerView;

@end

@implementation SampuxRegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationItem setHidesBackButton:YES];
    [self createRegisterView];
}


- (void)createRegisterView
{
    _registerView = [[SampuxRegisterView alloc]initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height )];
    [self.view addSubview:_registerView];
    __weak typeof(SampuxRegisterViewController *) wSelf = self;
    _registerView.registerBtnBlock = ^ (NSString *phoneNum,NSString *passwordNum)
    {
        dispatch_async(dispatch_get_main_queue(), ^{
            SampuxLoginViewController *aViewController = [wSelf.navigationController.viewControllers objectAtIndex:0];
            aViewController.loginView.phoneView.textFiled.text = phoneNum;
            aViewController.loginView.passWordView.textFiled.text = passwordNum;
            [wSelf.navigationController popViewControllerAnimated:YES];
        });
    };

    _registerView.agreementTapBlock = ^{
        SampuxProtocolViewController *agreementVC = [[SampuxProtocolViewController alloc]init];
        [wSelf.navigationController pushViewController:agreementVC animated:YES];
    };
    _registerView.existBtnBlock = ^{
        [wSelf.navigationController popViewControllerAnimated:YES];
    };
    
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    SampuxCustomNavController *nav = (SampuxCustomNavController *)self.navigationController;
    nav.titleStr = @"新用户注册";
}



@end
